<%@ include file = "/common/ini.jsp"%>
<%@ include file = "/common/_log4j.jsp"%>
<%@ include file = "/common/_ApplicationContext_init.jsp"%>
<%@ include file = "/common/_vr.jsp"%>
<%@ include file = "/js/_js_for_select.jsp"%>
<%
    // 定义名称
    String title = "修改机构";
    OrgManager orgManager = (OrgManager)applicationContext.getBean("orgManager");
    Org org = (Org)orgManager.get(request.getParameter("id"));
    String remark = "";
%>
<script>
    function submitData()
    {
        detailForm.serviceURL.value = "sysframe.org.UpdateOrgService";
        if(detailForm.parentId.value == "null")
        {
            detailForm.parentId.disabled = true;
        }
        detailForm.submit();
    }

    function reset()
    {
        detailForm.code.disabled = true;
        detailForm.id.value="<%= org.getId()%>";
        detailForm.code.value = "<%= org.getCode()%>";
        <%
        String parentId = null;
        if(vr.isAllValidated())
        {
            if(org.getSuperOrg() != null)
            {
                parentId = org.getSuperOrg().getId();
                %>addOption(detailForm.parentId,"<%= org.getSuperOrg().getId()%>","<%= org.getSuperOrg().getName()%>");<%
            }
            %>
            detailForm.parentId.value = "<%= parentId%>";
            detailForm.name.value = "<%= org.getName()%>";
            detailForm.country.value = "<%= org.getCountry()%>";
            detailForm.province.value = "<%= org.getProvince()%>";
            detailForm.city.value = "<%= org.getCity()%>";
            detailForm.street.value = "<%= org.getStreet()%>";
            detailForm.office.value = "<%= org.getOffice()%>";
            detailForm.linkMan.value = "<%= org.getLinkMan()%>";
            detailForm.phone.value = "<%= org.getPhone()%>";
            detailForm.fax.value = "<%= org.getFax()%>";
            detailForm.site.value = "<%= org.getSite()%>";
            detailForm.email.value = "<%= org.getEmail()%>";
            <%
            remark = org.getRemark();
        }
        else
        {
            if(request.getParameter("parentId") != null)
            {
                Org superOrg = (Org)orgManager.get(request.getParameter("parentId"));
                parentId = superOrg.getId();
                %>addOption(detailForm.parentId,"<%= superOrg.getId()%>","<%= superOrg.getName()%>");<%
            }
            %>
            detailForm.parentId.value = "<%= request.getParameter("parentId")%>";
            detailForm.name.value = "<%= request.getParameter("name")%>";
            detailForm.country.value = "<%= request.getParameter("country")%>";
            detailForm.province.value = "<%= request.getParameter("province")%>";
            detailForm.city.value = "<%= request.getParameter("city")%>";
            detailForm.street.value = "<%= request.getParameter("street")%>";
            detailForm.office.value = "<%= request.getParameter("office")%>";
            detailForm.linkMan.value = "<%= request.getParameter("linkMan")%>";
            detailForm.phone.value = "<%= request.getParameter("phone")%>";
            detailForm.fax.value = "<%= request.getParameter("fax")%>";
            detailForm.site.value = "<%= request.getParameter("site")%>";
            detailForm.email.value = "<%= request.getParameter("email")%>";
            <%
            remark = request.getParameter("remark");
        }
        %>
    }

    function addSubOrg()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/sysframe/org/addOrg.jsp?parentId=<%= org.getId()%>";
    }

    function bodyLoadJS()
    {
        // 被聚焦的控件
        detailForm.name.focus();
    }
</script>
<%@ include file = "/common/detail/_OnForm.jsp"%>
<%@ include file = "_detail.jsp"%>
<%@ include file = "/common/detail/_UnderFom_OnButton.jsp"%>
          <input  type="button" value="提交" afterFocused="" of="true" onclick="submitData()">
          &nbsp;&nbsp;<input  type="button" onclick="addSubOrg()" value="添加子机构">
          &nbsp;&nbsp;<input  type="button" onclick="reset()" value="重置">
          &nbsp;&nbsp;<input  type="button" onclick="goback()" value="返回">
<%@ include file = "/common/detail/_UnderFom_underButton.jsp"%>
